<template>
  <div>
      <div>
      <el-form  :inline="true" :model="A">
            <el-form-item prop="" label="套餐名称">
                <el-input v-model="A.setMealName" placeholder="请输入内容"  ></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="success" icon="el-icon-search" @click="taomtk()"></el-button>
            </el-form-item>
            <el-button type="primary" style="margin-left: 300px" @click="tianjia()">添加</el-button>
        </el-form>
    </div><br>
        <el-table border :data="Data.slice((currentPage-1)*pagesize,currentPage*pagesize)" style="width: 100%">
         <el-table-column prop="id" label="套餐ID" ></el-table-column>
         <el-table-column prop="setMealName" label="套餐名称" ></el-table-column>
         <el-table-column prop="img" label="套餐图片" ></el-table-column>
         <el-table-column prop="pkName" label="套餐类型" ></el-table-column>
         <el-table-column prop="campusName" label="适用园区" ></el-table-column>
         <el-table-column prop="price" label="套餐价格（元）" ></el-table-column>
         <el-table-column prop="pkMenu" label="套餐项目" ></el-table-column>
         <el-table-column label="操作" v-slot="a">
             <el-button type="primary" size="mini" @click="xiugai(a.row)">修改</el-button>
             <el-button type="primary" size="mini" @click="shanchu(a.row)">删除</el-button>
         </el-table-column>
      </el-table>
      <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[3, 5, 7]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="Data.length">
        </el-pagination>
    <div>
      <el-dialog title="是否删除" :visible.sync="delmtk" :model="del">
        <el-button type="primary" @click="delMeal()">确定</el-button>
        <el-button type="primary" @click="delmtk=false" >取消</el-button>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
    created(){
        this.finMealAll();
    },
    data(){
        return{
            Data:[],
            upd:{},
            delmtk:false,
            del:{},
            A:{setMealName:''},
            headertitle: "",
            centerDialogVisible:false,
            pagesize:3,
            currentPage:1,
        }
    },
    methods:{
        finMealAll(){
           
            this.$axios.get("/user/user/doctor/ren/finMealAll").then(res=>{ console.log(res.data.data.list)
                this.Data=res.data.data.list
            })
        },
         xiugai(row){
          this.$router.push({path: "/MealUpd",query: {row: row}});
          this.upd = {...row}
        },
        tianjia(){
            this.$router.push({path: "/MealAdd"});
        },
        shanchu(row){
            this.delmtk=true;
            this.del = { ...row };
        },
        delMeal(){
            this.$axios.post("/user/user/doctor/ren/delMeal",this.del).then(res=>{
            this.delmtk=false;
            this.finMealAll();
            })
        },
        taomtk(){
           this.$axios.get("/user/user/doctor/ren/taomtk",{params:{setMealName:this.A.setMealName}}).then(res=>{
                this.Data = res.data.data.list;
          })  
        },
        handleSizeChange(size) {
            this.pagesize = size;
        },
        handleCurrentChange(currentPage) {
                this.currentPage = currentPage;
      }
    }
}   
</script>

<style>

</style>